* Table of summary stats for interpolated tracks 
* compares average distances traveled pre/post ECA for different routes

local folder rd_regs

capture drop samp 
gen samp = 1 if route_type=="LongInterp" & interp_in_enterexit==1 & inlist(AKport,1,0) & (vesseltype_regstr=="Container") & (t_eca09<=150) & (t_eca09>=-150) 

*tabstat dist if samp==1 , by(eca_ind) stat(mean min max N)
capture drop route_pol
egen route_pol = group(AKport eca_ind) if samp==1, label
label define route_pol 1 "Pre" 2 "Post" 3 "Pre" 4 "Post" , replace

capture drop tmp_*
capture drop dist_outside_study
capture drop dist_outside_study_v2
gen dist_outside_study = dist - dist_entexit
gen dist_outside_study_v2 = dist - km_studyarea
label var dist_outside_study "Distance Outside Study Area"
label var dist_outside_study_v2 "Distance Outside Study Area"
gen tmp_dist = dist
label var tmp_dist "Total Distance"
gen tmp_dist_eca = dist_eca2009
label var tmp_dist_eca "Distance in ECA"
gen tmp_dist_entexit = dist_entexit
label var tmp_dist_entexit "Distance Within Study Area"
 
label var  td_inm_comply_cons_entexit "Damage within Study Area"
label var  cost_comply_cons_entexit "Fuel Cost within Study Area"
  
  
local dist_vars tmp_dist_eca tmp_dist tmp_dist_entexit dist_outside_study cost_comply_cons_entexit td_inm_comply_cons_entexit
 
eststo clear	
bysort route_pol: eststo: quietly estpost summarize `dist_vars'  if samp==1 & inlist(port_agg,"SoCal") , listwise	
esttab using "`folder'/interp_dist_2009.tex" , replace /// 
		cell( mean(fmt(1)) (sd(par fmt(1))) ) noline  nodepvar nonotes nostar nonumber  collabels(none) eqlabels(none)   /// eqlabels(none) 
		booktabs label  frag  ///
		mgroups( "Hawaii" "Unimak" , pattern(1 0 1 0 ) ///
		prefix(\multicolumn{@span}{c}{) suffix(})  ///
		span erepeat(\cmidrule(lr){@span}) ) ///
		posthead(\midrule \multicolumn{4}{l}{\textbf{(i) Southern California}}\\  )

eststo clear	
bysort route_pol: eststo: quietly estpost summarize `dist_vars' if samp==1 & inlist(port_agg,"NoCal") , listwise	
esttab  using "`folder'/interp_dist_2009.tex" , append ///
		cell( mean(fmt(1)) (sd(par fmt(1))) )  noline  nodepvar nonotes nostar nonumber collabels(none) nomtitle eqlabels(none)   /// collabels(none) nomtitle eqlabels(none)
		booktabs label  frag postfoot(\bottomrule) prehead( \\ \multicolumn{4}{l}{\textbf{(ii) Northern California}}\\)

drop tmp_*				
